<?php

/*
 * OMS职员监控数据
 */

namespace app\index\controller;

/**
 * Description of Monitor
 *
 * @author tommy.pan
 */
use app\common\model\oms\MonitorAttrStaff;
use app\common\model\oms\MonitorAttrDevice;
use app\common\model\oms\MonitorAttrStore;

class Monitor extends \app\common\controller\AuthBase {

    private $_monitor_model;

    public function __construct() {
        parent::__construct();
    }

    /**
     * 添加一条监控记录
     */
    public function addLogs() {

        $params = $this->input();
        //过滤所需参数是存在
        if (false === empty($params)) {
            switch ($params['type']) {
                case 'staff':
                    $this->_monitor_model = new MonitorAttrStaff();
                    break;
                case 'device':
                    $this->_monitor_model = new MonitorAttrDevice();
                    break;
                case 'store':
                    $this->_monitor_model = new MonitorAttrStore();
                    break;
                default :
                    return $this->output($params = [], $msg = '没有该类型的监控数据');
            }
            unset($params['type']);
            $res = $this->_monitor_model->save($params);
            if ($res) {
                return $this->output([]);
            }
            
        }
        return $this->output($params = [], $msg = '监控数据提交失败');
    }

}
